﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TouTiao.aspx.cs" Inherits="WAD.WEB.Client.Page.TouTiao" %>


        <script data-from="toutiao">
    var __placeholder_start = +new Date();
    var __placeholder_load_cost = -1;
    function onPlaceHolderLoaded() {
        if(window.__perf_st) {
            __placeholder_load_cost = +new Date() - __placeholder_start;
        }
    }
</script>
<%=html %>

<script src="../js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="gethtml.aspx?source=toutiao&id=<%=json_id %>" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        load();
        loadTitle();
        $(".article__header").css("display", "none");
        $(".body-placeholder").css("display", "none");
        $(".comments-container").css("display", "none");
        $(".comments-container").html("");
    });
    function load() {
        //if ($(".article-container .title"))
        //    $(".article-container .title").text(json.data.title);
        //if ($(".article-content"))
        //    $(".article-content").html(json.data.content);
        //else {
        //    $("#main").html(json.data.content);
        //}

        //$("p").before("<p>Hello world!</p>");
        var article = json.data;
        var auth = json.data.media_user;

        var title = "<div class='article__header'><h1 class='article__title'>" + json.data.title + "</h1></div>";
        var author = '<div class="article__author"><div class="header-left"><div class="avatar "><img src="' + auth.avatar_url + '"></div><div class="author-info"><span class="author-name">' + auth.user_auth_info.auth_info + '</span><span class="v-info v-' + auth.user_auth_info.auth_type + '"></span></div></div><div class="header-right"><span class="new-style-test-article-publish-time">7小时前</span><span class="dot"></span><span class="new-style-test-article-comment">1评论</span></div></div>';
        author = "";
        var content = "<div class='article__content' id='article_content'>" + json.data.content + "</div>";
        $(".top-banner-container").after("<article class='article'><div style='height: auto;'>" + title + author + content + "</div></article>");
    }

    function loadTitle() {
        var arrList = new Array();
        var i = 0;
        $(".article-content").find("img").each(function () {
            if (i < 8 && $(this).width() > 200) {
                arrList[i] = $(this).attr("src");
                i++;
            }
        });
        Set(json.data.title, arrList);
    }

    //设置title,logo
    var logoItemHtml = '' + '<div class="col-xs-3"><img class = "logoItem" src="{src}" /></div>';
    function Set(title, imgList) {
        $_p("#title").val(title);

        // 默认第一张图片为头图
        if (imgList.length > 0) {
            $_p(".logo").attr("src", imgList[0]);
        }
        $(imgList).each(function () {
            $_p("#imgList").append(logoItemHtml.replace(/{src}/, this));
        });

        // 候选图片点击事件
        $_p(".logoItem").off("click");
        $_p(".logoItem").on("click", function () {
            $_p(".logo").attr("src", $(this).attr("src"));
        });
    }

    function js_date_time(unixtime) {
        var timestr = new Date(parseInt(unixtime) * 1000);
        var datetime = timestr.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
        return datetime.substring(5);
    }

    function $_p(id) {
        return $(id, window.parent.document);
    }
</script>

<script src='//s3a.pstatp.com/growth/fe_sdk/reportsdk/sdk.js?t=26125075'></script>
<script src="//s2.pstatp.com/growth/confucius/confs/toutiao.growth.mobile_detail_web-page_config-all_config.js?t=26125075"></script>

<script src="//s1.pstatp.com/growth/mobile_detail/js/vendors.wv8gk80T.js" crossorigin="anonymous"></script>
<script src="//s1.pstatp.com/growth/mobile_detail/js/weixin.BY3y0PZq.js" crossorigin="anonymous"></script>



